<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<script type="text/javascript" src="../lib/jquery/jquery-1.11.1.js" ></script>
		<script type="text/javascript">
			function f1(){
				console.log($('input:checked'));
				var str = "";
				for (var i = 0;i < $('input:checked').length;i++) {
					var inputTemp = $('input:checked')[i];
					var value = inputTemp.value + ",";
					str += value;
				}
				str = str.substr(0,str.length-1);
				console.log(str);
			}
			function f2(){
				$('.hby').val([22,33]);
			}
		</script>
	</head>
	<body>
		<h1>复选框操作</h1>

        爱好：
        <input type="checkbox" class="hby" name="hobby" value="11" />篮球&nbsp;
        <input type="checkbox" class="hby" name="hobby" value="22" />足球&nbsp;
        <input type="checkbox" class="hby" name="hobby" value="33" />排球&nbsp;
        <input type="checkbox" class="hby" name="hobby" value="44" />乒乓球&nbsp;
        
        <br /><br />
        <input type="button" value="获取" onclick="f1()" />
        <input type="button" value="设置" onclick="f2()" />
	</body>
</html>
